/*CjdOFi+b4zn0Uw78z800P+o+eOc0B4ATn882C8HqunEOy4cZ7/8/43wDrhvpycWD*/
import { ajax } from 'nc-lightapp-front';

/**
 * 红蓝对冲,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function hldcChkBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    if (value.value == true) {
        props.form.setFormItemsRequired(hxgzCode, { 'jefxCmbBox': false })
        props.form.setFormItemsDisabled(hxgzCode, { jefxCmbBox: true });
        props.form.setFormItemsValue(hxgzCode, { 'jefxCmbBox': { value: null, display: null } });
    } else {
        props.form.setFormItemsRequired(hxgzCode, { 'jefxCmbBox': true })
        props.form.setFormItemsDisabled(hxgzCode, { jefxCmbBox: false });
        props.form.setFormItemsValue(hxgzCode, { 'jefxCmbBox': { value: 0, display: that.state.json['verificationsheet-000025'] } });/* 国际化处理： 正*/
    }
}

/**
 * 同币种核销,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function tbzhxChkBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    if (value.value == true) {
        props.form.setFormItemsDisabled(hxgzCode, {
            zjbzRef: true, yxwcTxtF: true,
            jfbzRef: true, jfbz_dzjbzhlTxtF: true,
            jfbz_dbbhlTxtF: true, dfbzRef: true,
            dfbz_dbbhlTxtF: true, dfbz_dzjbzhlTxtF: true, hxbzRef: false
        });
        props.form.setFormItemsValue(hxgzCode, { 'ybzhxChkBox': { value: null, display: null } });
        let pk_org = props.form.getFormItemsValue(cytjCode, 'pk_org');
        if (pk_org && pk_org.value) {
            props.form.setFormItemsValue(hxgzCode, { 'hxbzRef': { value: '1002Z0100000000001K1', display: that.state.json['verificationsheet-000045'] } });/* 国际化处理： 人民币*/
        }
    }
}

/**
 * 异币种核销,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function ybzhxChkBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    if (value.value == true) {
        props.form.setFormItemsDisabled(hxgzCode, {
            zjbzRef: false, yxwcTxtF: false,
            jfbzRef: false, jfbz_dzjbzhlTxtF: false,
            jfbz_dbbhlTxtF: false, dfbzRef: false,
            dfbz_dbbhlTxtF: false, dfbz_dzjbzhlTxtF: false, hxbzRef: true
        });
        props.form.setFormItemsValue(hxgzCode, { 'tbzhxChkBox': { value: null, display: null } });
        props.form.setFormItemsValue(hxgzCode, { 'hxbzRef': { value: null, display: null } });
    } else {
        props.form.setFormItemsDisabled(hxgzCode, {
            zjbzRef: true, yxwcTxtF: true,
            jfbzRef: true, jfbz_dzjbzhlTxtF: true,
            jfbz_dbbhlTxtF: true, dfbzRef: true,
            dfbz_dbbhlTxtF: true, dfbz_dzjbzhlTxtF: true, hxbzRef: false
        });
    }
}

/**
 * 中间币种,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function zjbzRef_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode, arapFlag) {
    let zjbz = props.form.getFormItemsValue(hxgzCode, 'zjbzRef').value;
    let jfbz = props.form.getFormItemsValue(hxgzCode, 'jfbzRef').value;
    let dfbz = props.form.getFormItemsValue(hxgzCode, 'dfbzRef').value;
    let pk_org = props.form.getFormItemsValue(cytjCode, 'pk_org').value;

    if (pk_org == "") {
        return;
    }
    ajax({
        url: '/nccloud/arap/verifyfa/afterEvent.do',
        data: {
            key: 'zjbzRef',
            value: value.value,
            zjbz: zjbz,
            jfbz: jfbz,
            dfbz: dfbz,
            pk_org: pk_org,
            arapFlag: arapFlag
        },
        success: (res) => {
            if (res.success) {
                if (res.data) {
                    let yxwc = props.form.getFormItemsValue(hxgzCode, 'yxwcTxtF');
                    let yxwc_scale = res.data['zjbz']['yxwc'][0] * 1
                    let yxwc_value = yxwc.value == null ? null : parseFloat(yxwc.value).toFixed(yxwc_scale)
                    props.form.setFormItemsValue(hxgzCode, { 'yxwcTxtF': { value: yxwc_value, display: yxwc_value, scale: yxwc_scale } });
                    if (jfbz) {
                        if (res.data['jfbz'] && res.data['jfbz']['midrate']) {
                            props.form.setFormItemsValue(hxgzCode, { 'jfbz_dzjbzhlTxtF': { value: res.data['jfbz']['midrate'][0], display: res.data['jfbz']['midrate'][0], scale: res.data['jfbz']['midrate'][1] * 1 } });
                            if (res.data['jfbz']['midrate'][0] == 1) {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    jfbz_dzjbzhlTxtF: true
                                });
                            } else {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    jfbz_dzjbzhlTxtF: false
                                });
                            }
                        }else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dzjbzhlTxtF: false
                            });
                        }
                        if (res.data['jfbz'] && res.data['jfbz']['hl']) {
                            props.form.setFormItemsValue(hxgzCode, { 'jfbz_dbbhlTxtF': { value: res.data['jfbz']['hl'][0], display: res.data['jfbz']['hl'][0], scale: res.data['jfbz']['hl'][1] * 1 } });
                            if (res.data['jfbz']['hl'][0] == 1) {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    jfbz_dbbhlTxtF: true
                                });
                            } else {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    jfbz_dbbhlTxtF: false
                                });
                            }
                        }else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dbbhlTxtF: false
                            });
                        }
                    }
                    if (dfbz) {
                        if (res.data['dfbz'] && res.data['dfbz']['midrate']) {
                            props.form.setFormItemsValue(hxgzCode, { 'dfbz_dzjbzhlTxtF': { value: res.data['dfbz']['midrate'][0], display: res.data['dfbz']['midrate'][0], scale: res.data['dfbz']['midrate'][1] * 1 } });
                            if (res.data['dfbz']['midrate'][0] == 1) {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    dfbz_dzjbzhlTxtF: true
                                });
                            } else {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    dfbz_dzjbzhlTxtF: false
                                });
                            }
                        }
                        else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dzjbzhlTxtF: false
                            });
                        }
                        if (res.data['dfbz'] && res.data['dfbz']['hl']) {
                            props.form.setFormItemsValue(hxgzCode, { 'dfbz_dbbhlTxtF': { value: res.data['dfbz']['hl'][0], display: res.data['dfbz']['hl'][0], scale: res.data['dfbz']['hl'][1] * 1 } });
                            if (res.data['dfbz']['hl'][0] == 1) {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    dfbz_dbbhlTxtF: true
                                });
                            } else {
                                props.form.setFormItemsDisabled(hxgzCode, {
                                    dfbz_dbbhlTxtF: false
                                });
                            }
                        }else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dbbhlTxtF: false
                            });
                        }

                    }
                }
            }
        }
    })
}

/**
 * 借方币种,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function jfbzRef_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode, arapFlag) {
    let zjbz = props.form.getFormItemsValue(hxgzCode, 'zjbzRef').value;
    let jfbz = props.form.getFormItemsValue(hxgzCode, 'jfbzRef').value;
    let pk_org = props.form.getFormItemsValue(cytjCode, 'pk_org').value;

    if (zjbz == "" || pk_org == "") {
        return;
    }
    ajax({
        url: '/nccloud/arap/verifyfa/afterEvent.do',
        data: {
            key: 'jfbzRef',
            value: value.value,
            zjbz: zjbz,
            jfbz: jfbz,
            pk_org: pk_org,
            arapFlag: arapFlag
        },
        success: (res) => {
            if (res.success) {
                if (res.data) {
                    if (res.data['jfbz'] && res.data['jfbz']['midrate']) {
                        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dzjbzhlTxtF': { value: res.data['jfbz']['midrate'][0], display: res.data['jfbz']['midrate'][0], scale: res.data['jfbz']['midrate'][1] * 1 } });
                        if (res.data['jfbz']['midrate'][0] == 1) {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dzjbzhlTxtF: true
                            });
                        } else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dzjbzhlTxtF: false
                            });
                        }
                    }
                    else {
                        props.form.setFormItemsDisabled(hxgzCode, {
                            jfbz_dzjbzhlTxtF: false
                        });
                    }
                    if (res.data['jfbz'] && res.data['jfbz']['hl']) {
                        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dbbhlTxtF': { value: res.data['jfbz']['hl'][0], display: res.data['jfbz']['hl'][0], scale: res.data['jfbz']['hl'][1] * 1 } });
                        if (res.data['jfbz']['hl'][0] == 1) {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dbbhlTxtF: true
                            });
                        } else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                jfbz_dbbhlTxtF: false
                            });
                        }
                    }else {
                        props.form.setFormItemsDisabled(hxgzCode, {
                            jfbz_dbbhlTxtF: false
                        });
                    }
                }
            }
        }
    })
}

/**
 * 借方币种-对中间币种汇率,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function jfbz_dzjbzhlTxtF_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    let scale1 = props.form.getFormItemsValue(hxgzCode, 'jfbz_dzjbzhlTxtF').scale
    let scale2 = props.form.getFormItemsValue(hxgzCode, 'jfbz_dbbhlTxtF').scale
    if (value.value) {
        let val = parseFloat(value.value).toFixed(scale2)
       // props.form.setFormItemsValue(hxgzCode, { 'jfbz_dbbhlTxtF': { value: val, display: val, scale: scale2 } });
    } else {
        let val1 = parseFloat('0.00000000').toFixed(scale1)
        let val2 = parseFloat('0.00000000').toFixed(scale2)
        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dzjbzhlTxtF': { value: val1, display: val1, scale: scale1 } });
        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dbbhlTxtF': { value: val2, display: val2, scale: scale2 } });
    }
}

/**
 * 借方币种-对本币汇率,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function jfbz_dbbhlTxtF_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    let scale1 = props.form.getFormItemsValue(hxgzCode, 'jfbz_dzjbzhlTxtF').scale
    let scale2 = props.form.getFormItemsValue(hxgzCode, 'jfbz_dbbhlTxtF').scale
    if (value.value) {
        let val = parseFloat(value.value).toFixed(scale1)
       // props.form.setFormItemsValue(hxgzCode, { 'jfbz_dzjbzhlTxtF': { value: val, display: val, scale: scale1 } });
    } else {
        let val1 = parseFloat('0.00000000').toFixed(scale1)
        let val2 = parseFloat('0.00000000').toFixed(scale2)
        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dzjbzhlTxtF': { value: val1, display: val1, scale: scale1 } });
        props.form.setFormItemsValue(hxgzCode, { 'jfbz_dbbhlTxtF': { value: val2, display: val2, scale: scale2 } });
    }
}

/**
 * 贷方币种,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function dfbzRef_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode, arapFlag) {
    let zjbz = props.form.getFormItemsValue(hxgzCode, 'zjbzRef').value;
    let dfbz = props.form.getFormItemsValue(hxgzCode, 'dfbzRef').value;
    let pk_org = props.form.getFormItemsValue(cytjCode, 'pk_org').value;

    if (dfbz == "" || pk_org == "") {
        return;
    }
    ajax({
        url: '/nccloud/arap/verifyfa/afterEvent.do',
        data: {
            key: 'dfbzRef',
            value: value.value,
            zjbz: zjbz,
            dfbz: dfbz,
            pk_org: pk_org,
            arapFlag: arapFlag
        },
        success: (res) => {
            if (res.success) {
                if (res.data) {
                    if (res.data['dfbz'] && res.data['dfbz']['midrate']) {
                        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dzjbzhlTxtF': { value: res.data['dfbz']['midrate'][0], display: res.data['dfbz']['midrate'][0], scale: res.data['dfbz']['midrate'][1] * 1 } });
                        if (res.data['dfbz']['midrate'][0] == 1) {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dzjbzhlTxtF: true
                            });
                        } else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dzjbzhlTxtF: false
                            });
                        }
                    } else {
                        props.form.setFormItemsDisabled(hxgzCode, {
                            dfbz_dzjbzhlTxtF: false
                        });
                    }
                    if (res.data['dfbz'] && res.data['dfbz']['hl']) {
                        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dbbhlTxtF': { value: res.data['dfbz']['hl'][0], display: res.data['dfbz']['hl'][0], scale: res.data['dfbz']['hl'][1] * 1 } });
                        if (res.data['dfbz']['hl'][0] == 1) {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dbbhlTxtF: true
                            });
                        } else {
                            props.form.setFormItemsDisabled(hxgzCode, {
                                dfbz_dbbhlTxtF: false
                            });
                        }
                    }else {
                        props.form.setFormItemsDisabled(hxgzCode, {
                            dfbz_dbbhlTxtF: false
                        });
                    }
                }
            }
        }
    })
}

/**
 * 贷方币种-对中间币种汇率,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function dfbz_dzjbzhlTxtF_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    let scale1 = props.form.getFormItemsValue(hxgzCode, 'dfbz_dzjbzhlTxtF').scale
    let scale2 = props.form.getFormItemsValue(hxgzCode, 'dfbz_dbbhlTxtF').scale
    if (value.value) {
        let val = parseFloat(value.value).toFixed(scale2)
       // props.form.setFormItemsValue(hxgzCode, { 'dfbz_dbbhlTxtF': { value: val, display: val, scale: scale2 } });
    } else {
        let val1 = parseFloat('0.00000000').toFixed(scale1)
        let val2 = parseFloat('0.00000000').toFixed(scale2)
        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dzjbzhlTxtF': { value: val1, display: val1, scale: scale1 } });
        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dbbhlTxtF': { value: val2, display: val2, scale: scale2 } });
    }
}

/**
 * 贷方币种-对本币汇率,编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} value 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 * @param {*} publicCode 
 * @param {*} hxgzCode 
 */
function dfbz_dbbhlTxtF_AfterEvent(that, props, value, cytjCode, bfCode, dfCode, publicCode, hxgzCode) {
    let scale1 = props.form.getFormItemsValue(hxgzCode, 'dfbz_dzjbzhlTxtF').scale
    let scale2 = props.form.getFormItemsValue(hxgzCode, 'dfbz_dbbhlTxtF').scale
    if (value.value) {
        let val = parseFloat(value.value).toFixed(scale1)
        //props.form.setFormItemsValue(hxgzCode, { 'dfbz_dzjbzhlTxtF': { value: val, display: val, scale: scale1 } });
    } else {
        let val1 = parseFloat('0.00000000').toFixed(scale1)
        let val2 = parseFloat('0.00000000').toFixed(scale2)
        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dzjbzhlTxtF': { value: val1, display: val1, scale: scale1 } });
        props.form.setFormItemsValue(hxgzCode, { 'dfbz_dbbhlTxtF': { value: val2, display: val2, scale: scale2 } });
    }
}
/**
 * 核销方案复制编辑后事件
 * @param {*} that 
 * @param {*} props 
 * @param {*} key 
 */
function copyFormPkorgAfterEvent(that,props,key,value){
     if(key=='pk_org'){
         that.pk_org=value.value.split(",");
         that.pk_verify_fa = that.pkfa;
     }
}


export {
    hldcChkBox_AfterEvent,
    tbzhxChkBox_AfterEvent,
    ybzhxChkBox_AfterEvent,
    zjbzRef_AfterEvent,
    jfbzRef_AfterEvent,
    jfbz_dzjbzhlTxtF_AfterEvent,
    jfbz_dbbhlTxtF_AfterEvent,
    dfbzRef_AfterEvent,
    dfbz_dzjbzhlTxtF_AfterEvent,
    dfbz_dbbhlTxtF_AfterEvent,
    copyFormPkorgAfterEvent
}
/*CjdOFi+b4zn0Uw78z800P+o+eOc0B4ATn882C8HqunEOy4cZ7/8/43wDrhvpycWD*/